package com.example.server.Outto;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Hashwith {
    public static String hashWithSHA256(String input) throws NoSuchAlgorithmException {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        byte[] hashBytes = messageDigest.digest(input.getBytes());
        StringBuilder hashString = new StringBuilder();

        for (byte b : hashBytes) {
            hashString.append(String.format("%02x", b));  // 转为十六进制字符串
        }

        return hashString.toString();
    }
}
